<?php
session_start();
require_once('../check_login.php');
include(dirname(__FILE__) . '/../config.php');
require_once('supports_lib.php');
require('../header.php');
$contacts = get_all_supports($_SESSION['id']);
?>

<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN SIDEBAR -->
    <?php require_once('../left_menu.php'); ?>

    <!-- END SIDEBAR -->
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <div class="page-content">
            <!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->

            <!-- /.modal -->
            <!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
            <!-- BEGIN STYLE CUSTOMIZER -->

            <!-- END STYLE CUSTOMIZER -->
            <!-- BEGIN PAGE HEADER-->
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->

                    <ul class="page-breadcrumb breadcrumb">

                        <li>
                            <i class="fa fa-home"></i>
                            <a href="dashboard.php">
                                Trang chủ
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>
                        <li>
                            <a href="#">
                                Các vấn đề cần giải quyết của tôi
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>

                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN EXAMPLE TABLE PORTLET-->
                    <div class="">

                        <div class="portlet-body">
                            <div class="table-toolbar">
                                <div class="btn-group">
                                    <button id="supports_table_new" class="btn green">
                                        Thêm mới <i class="fa fa-plus"></i>
                                    </button>
                                    
                                    
                                    
                                </div>
                                <div class="btn-group pull-right">
                                    <button class="btn dropdown-toggle" data-toggle="dropdown">Thao tác <i class="fa fa-angle-down"></i>
                                    </button>
                                    <ul class="dropdown-menu pull-right">
                                        <li>
                                            <a href="#">
                                                Đọc từ file Excel
                                            </a>
                                        </li>

                                    </ul>
                                </div>
                            </div>
                            <table class="table table-striped table-hover table-bordered" id="supports_table">
                                <thead>
                                    <tr>
                                        <th>
                                            Tiêu đề
                                        </th>

                                        <th>
                                            Nội dung
                                        </th>
                                        <th>
                                            Người phụ trách
                                        </th>
                                        <th>
                                            Trạng thái
                                        </th>
                                        <th>
                                            Ngày tạo
                                        </th>
                                        <th>
                                            Xem chi tiết
                                        </th>
                                        <th>
                                            Xóa
                                        </th>
                                        <th>
                                            Sửa
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>

                                    <?php foreach ($contacts as $contact) { ?>
                                        <tr>
                                            <td>
                                                <?php echo $contact['support_name'] ?>
                                            </td>
                                            <td>
                                                <?php echo $contact['description'] ?>
                                            </td>
                                            <td>
                                                <?php
                                                include_once(dirname(__FILE__) . '/../user/users_lib.php');
                                                if ($contact['assigned_to'] != 0) {
                                                    $u = get_user_detail($contact['assigned_to']);
                                                    echo $u['first_name'] . ' ' . $u['last_name'];
                                                }
                                                ?>
                                            </td>
                                            <td class="center">
                                                <?php
                                                switch ($contact['status']) {
                                                    case '1':
                                                        echo 'Tạo mới';
                                                        break;
                                                    case '2':
                                                        echo 'Đang được xử lý';
                                                        break;
                                                    case '3':
                                                        echo 'Đã được giải quyết';
                                                        break;
                                                    default:
                                                        break;
                                                }
                                                
                                                ?>
                                            </td>
                                            <td>
                                                <?php
                                                include_once(dirname(__FILE__) . '/../util.php');
                                                if ($contact['date_created'] != null) {
                                                    echo make_readable_time($contact['date_created']);
                                                }
                                                ?>
                                            </td>

                                            <td>
                                                <a href="<?php echo $url ?>/support/view_support_detail.php?id=<?php echo $contact['id'] ?>">
                                                    Xem chi tiết
                                                </a>
                                            </td>
                                            <td>
                                                <a class="delete" href="javascript:;">
                                                    Xóa
                                                </a>
                                            </td>
                                            <td>
                                                <a href="edit_support_detail.php?id=<?php echo $contact['id'] ?>">
                                                    Sửa chi tiết
                                                </a>
                                            </td>
                                        </tr>
                                    <?php } ?>


                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!-- END EXAMPLE TABLE PORTLET-->
                </div>
            </div>
            <!-- END PAGE CONTENT -->
        </div>
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
<?php
require_once('../footer.php');
require_once('../common_script.php');
?>

<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="<?php echo $url ?>/assets/scripts/core/app.js"></script>
<script src="<?php echo $url ?>/js/supports.js"></script>
<script>
    jQuery(document).ready(function () {
        App.init();
        TableEditable.init();
    });
</script>
</body>
<!-- END BODY -->
</html>